package org.bees.cms.web.interceptor;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import org.bees.cms.common.ThreadLocals;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.Interceptor;

public class EntityManagerInterceptor implements Interceptor {
	private static final long serialVersionUID = -5313543531130386788L;

	@PersistenceContext
	private EntityManager manager;

	@Override
	public void destroy() {
		// TODO Auto-generated method stub

	}

	@Override
	public void init() {
		// TODO Auto-generated method stub

	}

	@Override
	public String intercept(ActionInvocation invocation) throws Exception {
		ThreadLocals.ENTITY_MANAGERS.set(manager);
		return invocation.invoke();
	}

}
